/**
 * 
 */
package truerefactor.refactor;

import java.util.List;

import truerefactor.graph.ClassNode;
import truerefactor.graph.CodeGraph;
import truerefactor.graph.CodeNode;

/**
 * An implementation of the Change Bidirectional Association to Unidirectional
 * Refactoring Technique.
 * 
 * @author Isaac
 */
public class ChangeBiDirectional extends Refactoring {

    /**
     * 
     */
    public ChangeBiDirectional()
    {
        this.name = "Change BiDirection Association to UniDirectional";
        this.description = "";
    }

    /*
     * (non-Javadoc)
     * @see
     * truerefactor.refactor.Refactoring#execute(truerefactor.graph.CodeNode
     * [])
     */
    /**
     * Expects that each code node supplied is of the type ClassNode Also it
     * expects that the first node is to be pointed to while the second is to be
     * pointed from. In other words that the unidirectional association is from
     * the 2nd ... nth node to the first node.
     */
    @Override
    public void execute(CodeGraph graph)
    {
        // 1. Examine all the readers of the field that holds the pointer that
        // you wish to remove to see whether the removal is feasible
        // a. Look at direct readers and further methods that call methods.
        // b. Consider whether it is possible to determine the other object
        // without using the pointer. If so you will be able to use Substitute
        // Algorithm on the getter to allow clients to use the getting method
        // even if there is no pointer.
        // c. Consider adding the object as an argument to all methods that use
        // the field.

        // 2. If clients need to use the getter, use Self-Encapsulate Field,
        // carry out Substitute Algorithm on the getter.

        // 3. If clients don't need the getter, change each user of the field so
        // that it gets the object in the field another way.

        // 4. When no reader is left on the field, remove all updates to the
        // field, and remove the field.
        // a. if there are many places that assign the field, use Self
        // Encapsulate FIeld, so that they all use a single setter. Change the
        // setter to have an empty body. If that works, remove the field, the
        // setter, and all calls to the setter.
    }
}
